/*
 * ClockDelay.h
 *
 *  Created on: 2016年10月21日
 *      Author: zhengboyuan
 */

#ifndef CLOCKDELAY_H_
#define CLOCKDELAY_H_

#include "BasicType.h"
#include <stdint.h>


namespace util
{

class ClockDelay
{
public:
	static const int64_t	CLOCKRATE = 1000000;

public:
	ClockDelay();
	virtual ~ClockDelay();

	void setClockRate(int64_t rate);

	/**
	 * 计算延时, 返回值单位为毫秒
	 * @param pts
	 * @return
	 */
	int64_t getDelay(int64_t pts);

	bool getBeginTime(int64_t& clock, int64_t& pts);

	void reset();

	int64_t getDuration() const;

	static int64_t clock();

protected:
	int64_t	m_rate;
	int64_t	m_clock;
	int64_t m_pts;

};


} /* namespace util */

#endif /* CLOCKDELAY_H_ */
